package com.net.core.models.bean;

import java.util.ArrayList;
import java.util.List;

public enum Role {
    管理员(4l, "管理员", 10),
    经理(3l, "总监", 4),
    客服(2l, "经理", 2),
    玩家(1l, "开发", 1);

    Role() {
    }

    Role(Long id, String name, int level) {
        this.id = id;
        this.name = name;
        this.level = level;
    }

    String name;
    public int level;
    Long id;




    public static Role getRole(String roleName) {
        Role[] values = values();
        for (Role value : values) {
            if(value.name.equals(roleName)){
                return value;
            }
        }
        return null;
    }

    public static List<Role> getGmRole(String roleName) {
        Role role = getRole(roleName);
        List<Role> roles = new ArrayList<>();
        for (Role value : values()) {
            if(role.level>=value.level){
                roles.add(role);
            }
        }
        return roles;
    }

    public static List<String> getGmRoleName(String roleName) {
        Role role = getRole(roleName);
        List<String> roles = new ArrayList<>();
        for (Role value : values()) {
            if(role.level>=value.level){
                roles.add(value.name);
            }
        }
        return roles;
    }

    public static int compare(String roleName, String roleName1) {
        Role role = valueOf(roleName);
        Role role1 = valueOf(roleName1);
        return role.level-role1.level;
    }
}
